package site.assad.anno;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;


/**
 * Author: Al-assad 余林颖
 * E-mail: yulinying_1994@outlook.com
 * Date: 2017/11/30 0:03
 * Description: 演示 注解注入
 */

@Scope("prototype")
@Component("article")
public class Article {

    //自动注入
    @Autowired
    @Qualifier("user")
    private User user;

    public Article() {
        System.out.println("construct");
    }

    // @Autowired
    public void setUser(User user) {
        this.user = user;
    }

    public User getUser() {
        return user;
    }

    //对标准标签的支持
    @PostConstruct
    public void init1(){
        System.out.println("init1");
    }

    @PostConstruct
    public void init2(){
        System.out.println("init1");
    }

    @PreDestroy
    public void destory1(){
        System.out.println("destory1");
    }

    @PreDestroy
    public void destory2(){
        System.out.println("destory2");
    }





}
